/**
 * $Revision: 1.0 $
 * $Author: Eric Yang $
 * $Date: Aug 7, 2009 10:38:54 PM $
 *
 * Author: Eric Yang
 * Date  : Aug 7, 2009 10:38:54 PM
 *
 */
package com.gooex.service.common.impl;

import java.util.List;
import org.c4j.string.StringTools;
import org.c4j.system.web.exception.ServiceException;
import org.c4j.system.web.hibernate.BaseHibernateService;

import com.gooex.domain.common.Bulletin;
import com.gooex.service.common.IBulletinManager;

/**
 * @author Eric Yang
 * @version 1.0
 */
public class BulletinManagerImpl extends BaseHibernateService implements IBulletinManager {

	public Bulletin getBulletin(String id) {
		if (StringTools.isBlankOrNull(id))
			return null;
		return (Bulletin) getHibernateTemplate().get(Bulletin.class, id);
	}

	public List<Bulletin> getBulletins() {
		return getHibernateTemplate().find("from Bulletin");
	}

	public void saveBulletin(Bulletin bulletin) {
		if (StringTools.isBlankOrNull(bulletin.getId())) {
			bulletin.setId(null);
		}
		getHibernateTemplate().saveOrUpdate(bulletin);
	}

	public void removeBulletin(Bulletin product) throws ServiceException {
		product = getBulletin(product.getId());
		getHibernateTemplate().delete(product);
	}

}
